/*********************************************************************************
 *      Copyright:  (C) 2017 TangBin<tangbinmvp@gmail.com>
 *                  All rights reserved.
 *
 *       Filename:  adc_test.c
 *    Description:  This file 
 *                 
 *        Version:  1.0.0(04/07/2017)
 *         Author:  TangBin <tangbinmvp@gmail.com>
 *      ChangeLog:  1, Release initial version on "04/07/2017 03:01:33 PM"
 *                 
 ********************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>


/********************************************************************************
 *  Description:
 *   Input Args:
 *  Output Args:
 * Return Value:
 ********************************************************************************/
int main (int argc, char **argv)
{
    int fd;
    fd = open("/dev/S3C_ADC",0);
    if(fd < 0)
    {
        printf("open ADC device failed.\n");
        exit(1);
    }
    for(;;)
    {
        int ret;
        int data;

        ret = read(fd, &data, sizeof(data));
        if(sizeof(data) != ret)  
        {
            if(errno != EAGAIN)
            {
                printf("Read ADC Device Faild!\n");
            }
            continue;
        }
        else
        {
            printf("Read ADC value is: %d\n", data);
        }
        sleep(1);    
    }
    close(fd);
    return 0;
} /* ----- End of main() ----- */

